<template>
	<div style="margin-top: 40px;">

		<div style="width: 86%;">
			<div class="bgcorlor marg-20" style="margin-bottom: 20px;border: 1px solid #BABABA;">
				<div class="font20" style="padding: 10px 20px;border-bottom: 1px solid#BABABA;">商品基础信息</div>
				<div class="wai_pad">
					<el-form ref="form" :model="form" label-width="80px">
						<el-form-item label="*商品名称">
							<el-input v-model="form.storeGoodDto.goodName" placeholder="最多允许输入30个汉字(60个字符)" :maxlength='30' style="width: 80%;font-size: 16px;"></el-input>
						</el-form-item>
						<el-form-item label="*商品分组">
							<el-select v-model="form.storeGoodDto.goodOneCate" style="width: 200px;" @change="selectSort2()" placeholder="选择商品分组">
								<el-option :label="item.cateName" :value="item.cateId" :key="item.cateId" v-for="item in sortList"></el-option>
							</el-select>
							<el-button @click="addGroup()" type="primary" plain>新增</el-button>
						</el-form-item>

						<el-form-item label="*商品图片">
							<we-ui-uploads :images="form.storeGoodDto.goodCover" :maxCount="1" :maxSize="1024*1024" @uploading="uploading6"></we-ui-uploads>
						</el-form-item>
					</el-form>
				</div>
			</div>
			<div class="bgcorlor marg-20" style="margin-bottom: 20px;border: 1px solid #BABABA;">
				<div class="font20" style="padding: 10px 20px;border-bottom: 1px solid#BABABA;">销售信息</div>
				<div class="wai_pad">
					<el-form ref="form" :model="form" label-width="80px">
						<el-form-item label="*商品规格">
							<el-select v-model="sku_spec" style="width: 200px;margin-left: 10px;" @change="select()">
								<el-option :value="item" :label="item.spuName" v-for="item in sku_spec_array"></el-option>
							</el-select>
							<el-button style="margin-left: 20px;" class="btn btn-primary" @click.prevent="addSize()" type="primary">前往新增规格</el-button>
							<div style="">
								<div style="clear: both;padding-top: 15px;"></div>
								<div class="form-group" v-for="(item, index) in option_array" :key="index" style="clear: both;margin-left: 10px;margin-right: 10px;"
								 @change="generate">
									<label style="font-weight: bold;font-size: 14px;">{{item.spuName}}：</label>
									<div>
										<el-checkbox-group style="display: inline-block;margin-bottom: 0;" v-model="item.type_tag">
											<el-checkbox :label="val.spuName" v-for="val in item.goodSpuWebSecDtos"></el-checkbox>
										</el-checkbox-group>
										<button class="btn btn-default btn-sm" style="margin-left: 15px;" @click.prevent="delOption(index)">删除
										</button>
										<button class="btn btn-default btn-sm" style="margin-left: 15px;" @click.prevent="editSku(item)">编辑规格
										</button>
									</div>
								</div>
							</div>
							<!-- <div style="margin-bottom: 15px;" v-for="(items,index) in newSkuInfo" :key='index'>
								<div>
									<span>规格名</span>
									<el-autocomplete  onblur="confirmAddGroup(items.skuName)" class="inline-input" v-model="items.skuName" :fetch-suggestions="querySearch" placeholder="请输入内容"
									 @select="handleSelect"></el-autocomplete>
								</div>
								<div style="margin-top: 15px;display: flex;justify-content: flex-start;flex-wrap: wrap;">
									<span style="margin-right: 4px;">规格值</span>
									<div style="position: relative;margin-right: 20px;margin-bottom: 15px;" v-for="(item,i) in items.skuLis" :key="i">
										<el-select @change="showSkuTable" v-model="item.spuName" placeholder="请选择">
										    <el-option
										      v-for="ite in items.goodSku"
										      :key="ite.spuName"
										      :label="ite.spuName"
										      :value="ite.spuName">
										    </el-option>
										  </el-select>
										<img @click="deleteSpuName(index, i)" style="width: 20px; height: 20px;position: absolute;top: -10px;right: -10px;" src="../../../static/images/icon_colse.png" alt="">
									</div>
									<span @click="addSkuSpuName(index)" style="color: #0000C0;cursor: pointer;">添加规格值</span>
								</div>
							</div>
							<el-button @click="addSkuList()" type="primary" plain>添加规格项目</el-button> -->
						</el-form-item>
						<el-form-item label="规格明细">
							<table v-if="form.goodSkuWebDtos.length > 0" class="table">
								<thead>
									<tr>
										<!-- <th>缩略图</th> -->
										<th v-for="item in option_array">
											{{item.spuName}}
										</th>
										<th>价格</th>
										<th>包装费</th>
										<th>库存</th>
									</tr>
								</thead>
								<tbody class="spec-table">
							
									<tr v-for="(item,index) in form.goodSkuWebDtos">
										<!-- <td style="width: 100px;">
											<we-ui-uploads :images="item.skuIcon" :maxCount="1" :maxSize="1024*1024" @uploading="uploading"></we-ui-uploads>
										</td> -->
										<td v-for="val in item.goodSkuWebSecDtos">
											{{val.spuName}}
										</td>
										<td>
											<el-input style="width: 100px;" type="text" v-model="item.skuPrice" @blur="checkNum(item)" :maxlength="8"></el-input>
										</td>
										<td>
											<el-input style="width: 100px;" type="text" v-model="item.skuCostPrice" @blur="checkNum(item)" :maxlength="8"></el-input>
										</td>
										<td>
											<el-input style="width: 100px;" disabled placeholder="不限库存"></el-input>
										</td>
									</tr>
								
								</tbody>
							</table>
													
							<!-- <table class="table" id="tb">
								<thead>
									<tr>
										<th v-for="item in tableSkuInfo">
											{{item.skuName}}
										</th>
										<th>价格</th>
										<th>库存</th>
									</tr>
								</thead>
								<tbody class="spec-table">
							
									<tr v-for="(item,index) in tableData">
										<td v-for="val in item.goodSkuWebSecDtos">
											{{val.spuName}}
										</td>
										<td>
											<el-input style="width: 100px;" type="text" v-model="item.skuPrice" @blur="checkNum(item)" :maxlength="8"></el-input>
										</td>
									
										<td>
											<el-input style="width: 100px;" disabled placeholder="不限库存"></el-input>
										</td>
									</tr>
																	
								
								</tbody>
							</table> -->
													
						</el-form-item>
						
						
						<el-form-item label="*价格">
							 <el-input v-model="form.storeGoodDto.goodPrice" style="width: 192px"  placeholder="请输入内容">
							    <template slot="append">元</template>
							  </el-input>
						</el-form-item>

						<!-- <el-form-item label="包装费">
							<el-input style="width: 192px" placeholder="请输入内容" v-model="addProductPagePrice">
							   <template slot="append">元</template>
							 </el-input>
						</el-form-item> -->

					</el-form>
				</div>
			</div>
			<div class="bgcorlor font20 marg-20" style="border: 1px solid #BABABA;">
				<!-- <div class="border font20 marg-20 wai_pad">图文描述：</div> -->
				<div class="font20" style="padding: 20px;border-bottom: 1px solid#BABABA;">图文描述</div>
				<div class="wai_pad">
					<el-form ref="form" :model="form" label-width="80px">
						<el-form-item label="展示图">
							<we-ui-uploads :images="form.storeImgDtos" :maxCount="5" :maxSize="1024*1024" :isSort="true" @uploading="uploading2"></we-ui-uploads>
						</el-form-item>
						<el-form-item label="*主要原料">
								<div style="border:1px solid#BABABA;background: #FBF9FE;padding: 40px 40px 50px;margin-left: 10px;width: calc(90% - 100px);">
															<div style="display: flex;justify-content: flex-start;flex-wrap: wrap;">
																<div v-for="(item,index) in storeGoodParamDtos" :key="index" class="productSku">
																	<el-input v-model="item.paramKey" placeholder="例如材质" style="width: 100px;"></el-input>
																	<el-input v-model="item.paramName" placeholder="例如参数值" style="width: 100px;"></el-input>
																	<el-button type="danger" style="margin-left: 10px;" @click.prevent="delTexture(index,storeGoodParamDtos)">删除
																	</el-button>
																	<el-button type="primary" @click.prevent="addTexture()" v-if="index==0">新增
																	</el-button>
																</div>
															</div>
														</div>
						</el-form-item>
						<!-- <el-form-item label="*商品描述">
							<el-input v-model="form.storeGoodDto.goodName" placeholder="请输入" :maxlength='30' style="width: 90%;font-size: 16px;"></el-input>
						</el-form-item> -->
					</el-form>
				</div>
			</div>
			
			<div class="bgcorlor font20 marg-20" style="border: 1px solid #BABABA;">
				<div class="border_b font20 marg-20  wai_pad">其他信息</div>
				<div class="row" style="padding: 10px 20px;padding-bottom: 25px;">
					<el-form ref="form" :model="form">
						<el-form-item label="上架时间">
							<div>
								<el-radio-group v-model="form.storeGoodDto.goodState" style="padding-left: 20px;display: flex;align-items: center;margin-top: 7px;">
									<el-radio label="2" v-model="form.storeGoodDto.goodState">立即上架</el-radio>
									<el-radio label="3" v-model="form.storeGoodDto.goodState">放入仓库</el-radio>
											
									<!-- <el-radio :label="2">自定义邮费</el-radio>    -->
								</el-radio-group>
							</div>
						</el-form-item>
					</el-form>
				
				</div>
			</div>
			<!-- 类目 -->
		<!-- 	<div>
				<div class="font-26" style="margin-bottom: 15px;font-size: 20px;">商品基本信息</div>
				<div class=" row " style="padding: 20px;background-color: #FFFFFF;">
					<span style="line-height: 36px;">当前类目：</span>
					<el-select v-model="form.storeGoodDto.goodOneCate" style="width: 200px;" @change="selectSort2()" placeholder="一级分类">
						<el-option :label="item.cateName" :value="item.cateId" :key="item.cateId" v-for="item in sortList"></el-option>
					</el-select>
				</div>
			</div> -->
			<!-- 商品基本信息 -->
			<!-- <div class="bgcorlor marg-20" style="margin-bottom: 20px;">
				<div class="font20" style="padding: 20px;border-bottom: 1px solid#BABABA;">商品基础信息</div>
				<div class="wai_pad">
					<div>
						<div class="row">
							<div style="width: 100px;">*商品标题：</div>
							<el-input v-model="form.storeGoodDto.goodName" placeholder="最多允许输入30个汉字(60个字符)" :maxlength='30' style="width: 800px;margin-left: 10px;font-size: 16px;"></el-input>
						</div>
						<div style="font-size: 15px;margin-top: 10px;margin-bottom: 20px;color: #8a8a8a;margin-left: 110px;">*标题和描述关键词不可存在非法或敏感词汇，严重违规者封店处理</div>
					</div>
					<div style="width: 100%;" class="row">
						<div style="width: 100px;">*产品参数：</div>
						<div style="border:1px solid#BABABA;background: #FBF9FE;padding: 40px 40px 50px;margin-left: 10px;width: calc(90% - 100px);">
							<div style="display: flex;justify-content: flex-start;flex-wrap: wrap;">
								<div v-for="(item,index) in storeGoodParamDtos" :key="index" class="productSku">
									<el-input v-model="item.paramKey" placeholder="例如材质" style="width: 100px;"></el-input>
									<el-input v-model="item.paramName" placeholder="例如参数值" style="width: 100px;"></el-input>
									<el-button type="danger" style="margin-left: 10px;" @click.prevent="delTexture(index,storeGoodParamDtos)">删除
									</el-button>
									<el-button type="primary" @click.prevent="addTexture()" v-if="index==0">新增
									</el-button>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div> -->
			<!-- 销售信息 -->
			<div class="bgcorlor marg-20" style="margin-bottom: 20px;">
				<div>
					<!-- <div class="font20" style="padding: 20px;border-bottom: 1px solid#BABABA;">销售信息</div> -->
				<!-- 	<div class="row marg-20">
						<div class="newjust mar_l20" style="width: 100px;text-align: left;">*商品规格：</div>
						<el-select v-model="sku_spec" style="width: 200px;margin-left: 10px;" @change="select()">
							<el-option :value="item" :label="item.spuName" v-for="item in sku_spec_array"></el-option>
						</el-select>

						<el-button style="margin-left: 20px;" class="btn btn-primary" @click.prevent="addSize()" type="primary">前往新增规格</el-button>
					</div>
					 -->
			<!-- 		<div class="row marg-20">
						<div class="newjust mar_l20" style="width: 100px;text-align: left;">起售价：</div>
						<el-input style="width: 200px;margin-left: 10px;" :maxlength="8" v-model="form.storeGoodDto.goodPrice"></el-input>

					</div> -->
		<!-- 			<div>
						<div style="clear: both;padding-top: 15px;"></div>
						<div class="form-group" v-for="(item, index) in option_array" :key="index" style="clear: both;margin-left: 40px;"
						 @change="generate">
							<label style="font-weight: bold;font-size: 16px;">{{item.spuName}}：</label>
							<div>
								<el-checkbox-group style="display: inline-block;" v-model="item.type_tag">
									<el-checkbox :label="val.spuName" v-for="val in item.goodSpuWebSecDtos"></el-checkbox>
								</el-checkbox-group>
								<button class="btn btn-default btn-sm" style="margin-left: 15px;" @click.prevent="delOption(index)">删除
								</button>
							</div>
						</div>
					</div> -->
					
					<!-- <div style="padding: 0 25px;">
						<div class="box-body no-padding" style="clear: both;padding-top: 15px;">
							<table class="table">
								<thead>
									<tr>
										<th>缩略图</th>
										<th v-for="item in option_array">
											{{item.spuName}}
										</th>
										<th>价格</th>
									</tr>
								</thead>
								<tbody class="spec-table">

									<tr v-for="(item,index) in form.goodSkuWebDtos">
										<td style="width: 100px;">
											<we-ui-uploads :images="item.skuIcon" :maxCount="1" :maxSize="1024*1024" @uploading="uploading"></we-ui-uploads>
										</td>
										<td v-for="val in item.goodSkuWebSecDtos">
											{{val.spuName}}
										</td>
										<td>
											<el-input style="width: 100px;" type="text" v-model="item.skuPrice" @blur="checkNum(item)" :maxlength="8"></el-input>
										</td>

										<td>
										</td>
									</tr>
								
								</tbody>
							</table>
						
						</div>
					</div> -->
				
				</div>
			</div>
			<!-- 图文描述 -->
			<div class="bgcorlor font20 marg-20">
				<!-- <div class="border font20 marg-20 wai_pad">图文描述：</div> -->
			<!-- 	<div class="font20" style="padding: 20px;border-bottom: 1px solid#BABABA;">图文描述</div>
				<div class="wai_pad">
					<div class="row">
						<div class="font-17  marg-20" style="width: 110px;">商品缩略图：</div>

						<we-ui-uploads :images="form.storeGoodDto.goodCover" :maxCount="1" :maxSize="1024*1024" @uploading="uploading6"></we-ui-uploads>

					</div>
					<span style="font-size: 12px;color: #8A8A8A;display: block;margin-left: 124px;"> (尺寸:1:1,340*340) </span>
					<div class="row">
						<div class="font-17  marg-20" style="width: 110px;"> 商品轮播：</div>
						<we-ui-uploads :images="form.storeImgDtos" :maxCount="5" :maxSize="1024*1024" :isSort="true" @uploading="uploading2"></we-ui-uploads>
					</div>
					<span style="font-size: 12px;color: #8A8A8A;display: block;margin-left: 117px;">（尺寸:1:1,750*750,最多5张）</span>
					<div class="row font-15 marg-20">
						<div style="color: royalblue;margin-left: 123px;">重要提示：</div>
						<div style="font-size: 12px;color: #8A8A8A;line-height: 24px;">图片大小不可超过1M；850*850以上图片浏览效果更佳！</div>
					</div>
					<div class="row">
						<div class="font-17  marg-20" style="width: 110px;">商品详情：</div>
						<div style="max-width: 1000px;">
							<we-ui-uploads :images="form.storeImgDtoList" :maxCount="150" :maxSize="1024*1024" :isSort="true" @uploading="uploading3"></we-ui-uploads>
						</div>

					</div>
					<span style="font-size: 12px;color: #8A8A8A;display: block;margin-left: 120px;">（最多150张）</span>
				</div> -->
			</div>
			<!-- 支付信息 -->
			<div class="bgcorlor font20 marg-20">
				<!-- <div class="border_b font20 marg-20 wai_pad">支付信息</div>
				<div class="row wai_pad">
					<div class=" font-17">付款方式：</div>
					<el-radio-group v-model="radio" style="padding-left: 20px;display: flex;justify-content: center;align-items: center;margin-top: 5px;">
						<el-radio :label="1">一口价</el-radio>
						<el-radio :label="2">自定义邮费</el-radio>   
					</el-radio-group>
						<el-radio style="padding-left: 20px;display: flex;justify-content: center;align-items: center;margin: 0px;"
					 v-model="radio" label="1">一口价</el-radio>
				</div> -->
			</div>
			<!-- 物流信息 -->
			<div class="bgcorlor font20 marg-20">
				<!-- <div class="border_b font20 marg-20 wai_pad">物流信息</div>
				<div class="row  wai_pad">
					<div class="font-17">物流配送：</div>
					<el-radio-group v-model="wuliu" style="padding-left: 20px;display: flex;justify-content: center;align-items: center;margin-top: 5px;">
						<el-radio :label="1">包邮</el-radio>
					</el-radio-group>
				</div> -->
				<!-- 自定义邮费显示 -->
				<!-- <div class="row mar_t20 mar_b20" v-show="wuliu==2">
					<div class="row marg-20 font-17 mar_l20">
						<div class="just">默认邮费</div>
						<el-input style="width: 100px;padding: 0px 15px 0 15px;"></el-input>
						<div class="just">元</div>
					</div>
					<div class="row marg-20" style="margin-left: 70px;">
						<div class="just">偏远地区邮费</div>
						<el-input style="width: 100px;padding: 0px 15px 0 15px;"></el-input>
						<div class="just">元</div>
						<div class="just" style="margin-left: 50px;">偏远地区邮费（新疆、西藏等地区）</div>
					</div>
				</div> -->
			</div>
			<!-- 支付信息 -->
	<!-- 		<div class="bgcorlor font20 marg-20">
				<div class="border_b font20 marg-20  wai_pad">售后服务</div>
				<div class="row wai_pad" style="padding-left: 5px;">
					<div class="just font-17 mar_l20">售后服务：</div>
					<el-checkbox-group v-model="checkList" style="margin-top: 5px;margin-left:20px;">
						<el-checkbox label="1">提供发票</el-checkbox>
						<el-checkbox label="2">退换货承诺:该商品支持【七天退换】服务</el-checkbox>
					</el-checkbox-group>
				</div>
				<div class="row" style="padding-left: 25px;padding-bottom: 25px;">
					<div class=" font-17 ">上架时间：</div>
					<el-radio-group v-model="form.storeGoodDto.goodState" style="padding-left: 20px;display: flex;justify-content: center;align-items: center;margin-top: 5px;">
						<el-radio label="2" v-model="form.storeGoodDto.goodState">立即上架</el-radio>
						<el-radio label="3" v-model="form.storeGoodDto.goodState">放入仓库</el-radio>
					</el-radio-group>

				</div>
			</div>
			 -->
			<div class="just mar_t50 mar_b50 " style="padding: 20px;">
				<el-button type="primary" style="width: 300px;height: 50px;" @click="submitForm()">提交商品信息</el-button>
			</div>

		</div>
		<div class="addGroup">
			<el-dialog title="新增分组" :visible.sync="dialogVisible" width="20%" center :before-close="handleClose">
				<div>
					<el-form :model="formInline" label-width="120px" class="demo-form-inline">
						<el-form-item label="商品分组名称">
							<el-input style="width: 60%" v-model="formInline.cateName" placeholder="分组"></el-input>
						</el-form-item>
					</el-form>
				</div>
				<span slot="footer" class="dialog-footer">
					<el-button @click="dialogVisible = false">取 消</el-button>
					<el-button type="primary" @click="confirmAddGroup()">确 定</el-button>
				</span>
			</el-dialog>
		</div>
		
		
		<div>
			<el-dialog title="新增规格" :visible.sync="dialogVisibleAddSku" width="20%" center :before-close="handleClose">
				<div style="margin-bottom: 30px;">
				   <span>规格：</span>
				   <el-input style="width: 200px;" v-model="standard"></el-input>
				</div>
				<div>
				   <span>属性：</span>
				   <el-tag
				    :key="item.spuName"
				    v-for="item in dynamicTags"
				    :closable="true"
				    :close-transition="false"
				    @close="handleCloseSku(item)"
				    style="margin-left: 10px;"
				    >
				    {{item.spuName}}
				    </el-tag>
				    <el-input
				      class="input-new-tag"
				      v-if="inputVisible"
				      v-model="inputValue"
				      ref="saveTagInput"
				      size="mini"
				      @keyup.enter.native="handleInputConfirm"
				      @blur="handleInputConfirm"
				      :maxlength="16"
				    >
				    </el-input>
				    <el-button v-else class="button-new-tag" size="small" @click="showInput">+添加属性</el-button>
				</div>
				<div style="margin-top: 40px;margin-left: 50px;">
				   <el-button style="width: 300px;" type="primary"  @click="submit()">保存</el-button>
				</div>
			</el-dialog>
			
		</div>
	
	</div>


</template>
<style>
	#app {
		font-size: 17px;
	}

	.margl100 {
		margin-left: 100px;

	}

	.input_page {
		width: 270px;
		margin-left: 5px;
	}

	.wai_pad {
		padding: 20px;

	}

	.marg-20 {
		margin-top: 20px;
	}

	.border {
		border: 1px solid#BABABA;
	}

	.select {
		display: flex;
		padding: 10px;
		margin-top: 50px;

	}

	.mar_left {
		margin-left: 300px;
	}

	.juxing {
		color: white;
		background-color: #BFD1DE;
		display: inline-block;
		position: relative;
		top: -12px;
		height: 32px;
		line-height: 30px;
		width: 70%;
		text-align: center;
		left: 4px;
	}

	.jiantou {
		width: 0;
		height: 0;
		border-top: 16px solid transparent;
		border-left: 40px solid #BFD1DE;
		border-bottom: 16px solid transparent;
		display: inline-block;
	}

	.type {
		display: inline-block;
		width: 30%;
	}

	.acitve {
		background-color: #7C93A7;

	}

	.jiantou_active {
		border-left: 40px solid #7C93A7;
	}

	td .weui-cell {
		padding: 0;
	}

	.table>tbody>tr>td,
	.table>tbody>tr>th,
	.table>tfoot>tr>td,
	.table>tfoot>tr>th,
	.table>thead>tr>td,
	.table>thead>tr>th {
		vertical-align: middle;
	}

	.bgcorlor {
		background-color: #FFFFFF;
	}

	.newjust {
		display: flex;
		/* justify-content: center; */
		align-items: center;
	}

	.productSku {
		width: 47%;
		margin-right: 20px;
		margin-top: 10px;
	}

	.productSku:nth-child(2n) {
		margin-right: 0;
		width: 47%;
		margin-top: 10px;
	}

	.wai_pad .el-form-item__label {
		text-align: left;
	}

	.addGroup .el-dialog--small {
		width: 25%;
	}
</style>

<script>
	export default {
		data() {
			return {
				tableData: [],
				dialogVisible: false,
				formInline: {
					cateName: ''
				},
				addProductPrice: '0.00',
				addProductPagePrice: '0.00',
				disabledPrice: false,
				dialogVisibleAddSku: false,
				addSizeType: 'add',
				addSizeSpuId: '',
				dynamicTags: [],
				inputVisible: false,
				inputValue: '',
				standard:'',
				newSkuInfo: [],
				tableSkuInfo: [],
				checkList: ['2'],
				radio1: '1',
				wuliu: 1,
				radio: 1,
				code: '',
				brand: '',
				material: '',
				func: '',
				place: '',
				weight: '',
				classify: true,
				loading: false,
				fenlei1: '',
				fenlei2: '',
				fenlei3: '',
				form: {
					storeImgDtos: [],
					storeImgDtoList: [],
					goodSkuWebDtos: [],
					goodSpuWebDtos: [],
					storeGoodDto: {
						storeId: '',
						goodId: '',
						goodName: '',
						goodOneCate: '',
						goodTwoCate: 'enveN0000000021',
						goodThreeCate: '',
						goodPrice: '',
						// goodDiscountPrice: '',
						goodIsDiscount: '2',
						goodIdent: '2',
						goodIsFree: '1',
						goodIsStock: '2',
						goodState: '2',
						// goodRatio: 0.08,
						goodCover: []
					}

				},
				sortList: [],
				secondList: [],
				ThirdList: [],
				carriageList: [],
				proportion: [{
						text: '2%',
						value: 0.02
					}, {
						text: '4%',
						value: 0.04
					}, {
						text: '6%',
						value: 0.06
					},
					{
						text: '8%',
						value: 0.08
					}, {
						text: '10%',
						value: 0.1
					},
					{
						text: '12%',
						value: 0.12
					}, {
						text: '14%',
						value: 0.14
					},
					{
						text: '16%',
						value: 0.16
					}
				],
				sku_spec_array: [],
				sku_spec: '',
				option_array: [],
				type_tag: '1',
				show: true,
				flag: false,
				flag2: false,
				URL: URL,
				brandList: [],
				storeId: '',
				storeImgDtos: [],
				storeImgDtoList: [],
				imgDetailList: [],
				show_sed: '',
				storeGoodParamDtos: [{
					paramKey: '',
					paramName: ''
				}],
				firstVal: false,
				firstVal2: false,
				goodSkuWebDtos: [],
				type: ''
			}
		},
		created() {
			this.selectSort()
			this.fetchStandard()
			// this.fetchData2();
			this.storeId = JSON.parse(sessionStorage.getItem('permission')).storeId

			// console.log(this.storeId, '检测商铺id')
			this.form.storeGoodDto.storeId = JSON.parse(sessionStorage.getItem('permission')).storeId
			if (this.$route.params.id == 0) {
				this.form = {
					storeImgDtos: [],
					storeImgDtoList: [],
					goodSkuWebDtos: [],
					goodSpuWebDtos: [],
					storeGoodDto: {
						storeId: '',
						goodId: '',
						goodName: '',
						goodOneCate: '',
						goodTwoCate: '',
						goodThreeCate: '',
						goodPrice: '',
						// goodRatio: 0.08,
						// goodDiscountPrice: '',
						goodIsDiscount: '2',
						goodIdent: '2',
						goodIsFree: '1',
						goodIsStock: '2',
						goodState: '2',
						goodCover: []
					}

				}

			} else {
				this.fetchData()
			}
			// keep 点击新增规格，空时可以使用通id和 + 
			if (sessionStorage.getItem('keep') == 1) {
				sessionStorage.removeItem('keep')
			} else {
				this.option_array = []
				this.storeImgDtos = []
				this.storeImgDtoList = []
				this.form = {
					storeImgDtos: [],
					storeImgDtoList: [],
					goodSkuWebDtos: [],
					goodSpuWebDtos: [],
					storeGoodDto: {
						storeId: '',
						goodId: '',
						goodName: '',
						goodOneCate: '',
						goodTwoCate: '',
						goodThreeCate: '',
						goodPrice: '',
						// goodRatio: 0.08,
						// goodDiscountPrice: '',
						goodIsDiscount: '2',
						goodIdent: '2',
						goodIsFree: '1',
						goodIsStock: '2',
						goodState: '2',
						goodCover: []
					}

				}
				this.firstVal = false
				this.firstVal2 = false
				this.storeGoodParamDtos = [{
					paramKey: '',
					paramName: ''
				}]
				this.show = true


			}

			// console.log(this.option_array, '')

		},

		mounted() {
			if (sessionStorage.getItem('sku') == '1') {
				this.classify = false
				sessionStorage.removeItem('sku')
			}
		},

		activated() {

		},

		watch: {


			// '$route': 'fetchData2',

			// 'storeGoodParamDtos': {
			// 	handler: function(newValue, oldValue) {
			// 		if (this.firstVal) {
			// 			this.firstVal = false
			// 		} else {
			// 			this.form.storeGoodParamDtos = newValue
			// 		}

			// 	},
			// 	deep: true,
			// },
			// 'form.goodSkuWebDtos': {
			// 	handler: function(newValue, oldValue) {
			// 		if (this.firstVal2) {
			// 			this.firstVal2 = false
			// 		} else {
			// 			this.goodSkuWebDtos = newValue
			// 		}
			// 	},
			// 	deep: true,
			// }
		},
		methods: {
			// 获取规格，getSore

			addSize() {
				//新增规格

				var fenlei = [{
						fenlei1: this.fenlei1
					},
					{
						fenlei2: this.fenlei2
					},
					{
						fenlei3: this.fenlei3
					}

				]
				this.addSizeType = 'add'
				this.dialogVisibleAddSku = true
				// sessionStorage.setItem('fenlei', JSON.stringify(fenlei))
				// sessionStorage.setItem('storeGoodParamDtos', JSON.stringify(this.storeGoodParamDtos))
				// sessionStorage.setItem('form', JSON.stringify(this.form))
				// sessionStorage.setItem('option_array', JSON.stringify(this.option_array))
				// this.$router.push('/mall/size_list/' + '1')
			},
			editSku(data){
				console.log(data)
				this.addSizeType = 'edit'
				this.addSizeSpuId = data.spuId
				this.dataApi.ajax('selectShopSpu',{spuId:data.spuId}, res => {
				    if (res.responseType === 'S') {
				         this.standard=res.shopSpuDto.spuName
				         var arr=[]
				         for (var i=0;i< res.shopSpuDto.shopSpuSecDtos.length; i++) {
				           arr.push({
				            spuName:res.shopSpuDto.shopSpuSecDtos[i].spuName,
				            spuId:res.shopSpuDto.shopSpuSecDtos[i].spuId
				           })
				         }
				        this.dynamicTags=arr
						this.dialogVisibleAddSku = true
				    }
				});
			},

			fetchData() {
				// alert(this.$route.params.id)

				this.dataApi.ajax('singleStoreGood', {
					goodId: this.$route.params.id
				}, res => {
					if (res.responseType === 'S') {
						this.option_array = []
						this.form = res
						this.form.storeGoodDto.goodTwoCate = res.storeGoodDto.goodTwoCate
						this.form.storeGoodDto.goodThreeCate = res.storeGoodDto.goodThreeCate
						// console.log(this.form.storeGoodDto,'1111')

						console.log(this.form, 'form')
						for (var k in this.form.goodSkuWebDtos) {
							this.form.goodSkuWebDtos[k].skuIcon = [this.form.goodSkuWebDtos[k].skuIcon]
						}
						for (var k in res.goodSpuWebDtos) {
							var arr = []
							for (var j in res.goodSpuWebDtos[k].goodSpuWebSecDtos) {
								arr.push(res.goodSpuWebDtos[k].goodSpuWebSecDtos[j].spuName)
							}
							this.option_array.push({
								spuName: res.goodSpuWebDtos[k].spuName,
								spuId: res.goodSpuWebDtos[k].spuId,
								goodSpuWebSecDtos: res.goodSpuWebDtos[k].goodSpuWebSecDtos,
								type_tag: arr
							})
						}
						this.storeImgDtos = generateArr(res.storeImgDtos)
						this.storeImgDtoList = generateArr(res.storeImgDtoList)

						this.form.storeGoodDto.goodCover = [this.form.storeGoodDto.goodCover]
						for (var i = this.form.storeImgDtos.length - 1; i >= 0; i--) {
							this.form.storeImgDtos[i] = [this.form.storeImgDtos[i].imgUrl]
						}
						for (var i = this.form.storeImgDtoList.length - 1; i >= 0; i--) {
							this.form.storeImgDtoList[i] = [this.form.storeImgDtoList[i].imgUrl]
						}
						this.firstVal = true
						this.firstVal2 = true
						this.storeGoodParamDtos = res.storeGoodParamDtos
						delete this.form.storeGoodParamDtos
						this.show_sed = true
						if(this.storeGoodParamDtos.length == 0) {
							this.storeGoodParamDtos = [{
										paramKey: '',
										paramName: ''
										}]
						}


						// this.selectSort2()
						// this.selectSort3()
					}
				});
			},
			submitForm() {
				// 
				if (!this.form.storeGoodDto.goodOneCate) {
					this.$message({
						type: 'warning',
						message: '请选择分类!'
					});
					return false;
				}
				if (!this.form.storeGoodDto.goodName) {
					this.$message({
						type: 'warning',
						message: '请填写商品名称!'
					});
					return false;
				}
				// if (!this.form.storeGoodDto.goodPrice || !isFloat(this.form.storeGoodDto.goodPrice)) {
				// 	this.$message({
				// 		type: 'warning',
				// 		message: '商品起售价不正确!'
				// 	});
				// 	return false;
				// }
				// if (parseFloat(this.form.storeGoodDto.goodDiscountPrice) > parseFloat(this.form.storeGoodDto.goodPrice)) {
				// 	this.$message({
				// 		type: 'warning',
				// 		message: '商品现价不能大于原价!'
				// 	});
				// 	return false;
				// }
				// for (var i = 0; i < this.storeGoodParamDtos.length; i++) {
				// 	if (!this.storeGoodParamDtos[i].paramName || !this.storeGoodParamDtos[i].paramKey) {
				// 		this.showMsg('请填写完整产品参数', 'warning')
				// 		return
				// 	}
				// }
				if (this.option_array.length == 0) {
					this.$message({
						type: 'warning',
						message: '请至少选择一种规格!'
					});
					return false;
				}
				if (this.form.goodSkuWebDtos.length == 0) {
					this.$message({
						type: 'warning',
						message: '请选择规格属性!'
					});
					return false;
				}
				
				if (this.form.storeGoodDto.goodCover.length == 0) {
					this.$message({
						type: 'warning',
						message: '请上传商品图!'
					});
					return false;
				}
				// for (var i = this.form.goodSkuWebDtos.length - 1; i >= 0; i--) {
				// 	if (this.form.goodSkuWebDtos[i].skuIcon.length == 0) {
				// 		this.$message({
				// 			type: 'warning',
				// 			message: '请上传缩略图!'
				// 		});
				// 		return
				// 	}
				// }
				// if (this.form.storeGoodDto.goodCover.length == 0) {
				// 	this.$message({
				// 		type: 'warning',
				// 		message: '请上传商品缩略图!'
				// 	});
				// 	return false;
				// }

				// if (this.form.storeImgDtos.length == 0) {
				// 	this.$message({
				// 		type: 'warning',
				// 		message: '请上传商品轮播图!'
				// 	});
				// 	return false;
				// }

				// if (this.form.storeImgDtoList.length == 0) {
				// 	this.$message({
				// 		type: 'warning',
				// 		message: '请上传商品详情!'
				// 	});
				// 	return false;
				// }

				let data = generateObj(this.form)
				//删除没有选中的规格属性
				data.goodSpuWebDtos = this.option_array
				for (var i = this.option_array.length - 1; i >= 0; i--) {
					var arr = []

					for (var j = this.option_array[i].type_tag.length - 1; j >= 0; j--) {
						for (var k = this.option_array[i].goodSpuWebSecDtos.length - 1; k >= 0; k--) {
							if (this.option_array[i].goodSpuWebSecDtos[k].spuName == this.option_array[i].type_tag[j]) {
								arr.push(this.option_array[i].goodSpuWebSecDtos[k])
							}
						}
					}

					this.option_array[i].goodSpuWebSecDtos = arr
				}

				let storeGoodDto = generateObj(this.form.storeGoodDto)
				storeGoodDto.goodCover = storeGoodDto.goodCover + ''
				data.storeGoodDto = storeGoodDto
				if (this.goodSkuWebDtos.length != 0) {
					for (var i = data.goodSkuWebDtos.length - 1; i >= 0; i--) {
						data.goodSkuWebDtos[i].skuIcon = data.goodSkuWebDtos[i].skuIcon + ''
					}
				} else {
					// delete data.goodSkuWebDtos
				}

				//获取storeImgDtos图片列表的长宽
				var storeImgDtos = []
				for (var i = data.storeImgDtos.length - 1; i >= 0; i--) {
					for (var j = this.storeImgDtos.length - 1; j >= 0; j--) {
						if (this.storeImgDtos[j].imgUrl == data.storeImgDtos[i]) {
							storeImgDtos.push(this.storeImgDtos[j])
							break;
						}
					}
				}
				data.storeImgDtos = storeImgDtos.reverse()
				data.storeGoodParamDtos = this.storeGoodParamDtos

				//获取storeImgDtoList图片列表的长宽
				var storeImgDtoList = []
				for (var i = data.storeImgDtoList.length - 1; i >= 0; i--) {

					for (var j = this.storeImgDtoList.length - 1; j >= 0; j--) {
						if (this.storeImgDtoList[j].imgUrl == data.storeImgDtoList[i]) {
							storeImgDtoList.push(this.storeImgDtoList[j])
							break;

						}
					}
				}

				data.storeGoodDto.storeId = JSON.parse(sessionStorage.getItem('permission')).storeId
				data.storeImgDtoList = storeImgDtoList.reverse()
				this.loading = true
				console.log(data)
				if (this.$route.params.id == 0) {
					this.dataApi.ajax('addStoreGood', data, res => {
						if (res.responseType === 'S') {
							this.showMsg('新增成功')

							this.goBack()
							//this.$router.push('/mall/self_support')
						}
						this.loading = false
					});
				} else {
					this.dataApi.ajax('editStoreGood', data, res => {
						if (res.responseType === 'S') {
							this.$message({
								type: 'success',
								message: '编辑成功!'
							});

							this.goBack()
							//this.$router.push('/mall/self_support')
						}
						this.loading = false
					});
				}

			},
			fetchStandard() {
				this.dataApi.ajax('selectShopSpuList', null, res => {
					if (res.responseType === 'S') {
						this.sku_spec_array = res.shopSpuPojos
						console.log(this.sku_spec_array, 'sku_spec_array')
					}
				});
			},
			delOption(index) {
				this.option_array.splice(index, 1)
				this.generate()
			},
			generate() {
				var option_array = this.option_array;
				var spec_array = this.form.goodSkuWebDtos = [];
				if (option_array.length <= 0)
					return false;
				var select = [];
				for (var i in option_array) {
					if (option_array[i].type_tag.length > 0) {
						select.push(option_array[i].type_tag);
					} else{
						return
					}

				}
				var ret = this.doExchange(select)
				if(ret == undefined) {
					return
				}
				for (var i = 0; i < ret.length; i++) {
					var proObj = {};
					console.log(ret[i])
					var retArr = ret[i].split('|');
					proObj['goodSkuWebSecDtos'] = [];
					for (var y = 0; y < retArr.length; y++) {
						proObj['goodSkuWebSecDtos'].push({
							spuName: retArr[y]
						})

					}
					// proObj['skuIcon'] = [];
					proObj['skuPrice'] = 0.00;
					proObj['skuCostPrice'] = 0.00;
					// proObj['skuRatio'] = 0.08;
					spec_array.push(proObj);
				}
			},
			doExchange(doubleArrays) {
				var len = doubleArrays.length;

				if (len >= 2) {
					var len1 = doubleArrays[0].length;
					var len2 = doubleArrays[1].length;
					var newLen = len1 * len2;
					var temp = new Array(newLen);
					var index = 0;
					for (var i = 0; i < len1; i++) {
						for (var j = 0; j < len2; j++) {
							temp[index] = doubleArrays[0][i] + '|' + doubleArrays[1][j];
							index++;
						}
					}

					var newArray = new Array(len - 1);
					for (var i = 2; i < len; i++) {
						newArray[i - 1] = doubleArrays[i];
					}
					newArray[0] = temp;
					return this.doExchange(newArray);

				} else {
					return doubleArrays[0];
				}
			},
			select() {
				if (!this.sku_spec.spuId) {
					return false;
				}
				var arr = this.option_array;
				for (var i in arr) {
					if (arr[i].spuName === this.sku_spec.spuName) {
						this.sku_spec = ''
						return false;
					}
				}
				if (arr.length >= 5) {
					return false;
				}
				this.dataApi.ajax('selectShopSpuList', {
					spuId: this.sku_spec.spuId
				}, res => {
					//console.log(res.standardTagPojos)
					if (res.responseType === 'S') {
						this.option_array.push({
							spuName: this.sku_spec.spuName,
							spuId: this.sku_spec.spuId,
							goodSpuWebSecDtos: res.shopSpuPojos,
							type_tag: [],
						})
						this.generate()
						this.sku_spec = ''
					}
				});

			},
			confirm() {
				if (this.form.storeGoodDto.goodOneCate) {
					this.classify = false
				} else {
					this.$message({
						message: '请选择商品分类',
						type: 'warning'
					});

				}

			},
			selectSort() {
				//一级列表
				this.dataApi.ajax('selectGoodCate', {
					cateState: '1'
				}, res => {
					if (res.responseType === 'S') {
						this.sortList = res.dtos
					}
				});

			},

			selectSort2() {

				//获取一级分类名称
				this.sortList.forEach(item => {
					if (item.cateId == this.form.storeGoodDto.goodOneCate) {
						this.fenlei1 = item.cateName
						// console.log(this.fenlei1, 'fenlei1')
					}
				})
				// 二级；列表
				if (this.show_sed) {
					this.form.storeGoodDto.goodTwoCate = this.form.storeGoodDto.goodTwoCate
					this.show_sed = false
				} else {
					this.form.storeGoodDto.goodTwoCate = ''
				}

				this.dataApi.ajax('selectGoodCate', {
					cateId: this.form.storeGoodDto.goodOneCate,
					cateState: '1'
				}, res => {

					if (res.responseType === 'S') {
						this.secondList = res.dtos
					}
				});


			},
			uploading(f) {
				this.loading = true
				this.dataApi.upload('FileUploadNotify/upload', f.file, res => {
					if (res.responseType == 'S') {
						f.images.splice(f.index, 1, res.filePath)
						this.storeImgDtoList.push({
							imgHeight: res.height,
							imgUrl: res.filePath,
							imgWidth: res.width
						})
						console.log(this.storeImgDtoList.imgUrl)
						this.loading = false
					}
				});
			},
			uploading6(f) {
				this.loading = true
				this.dataApi.upload('FileUploadNotify/upload', f.file, res => {

					if (res.responseType == 'S') {
						f.images.splice(f.index, 1, res.filePath)
						this.storeImgDtoList.push({
							imgHeight: res.height,
							imgUrl: res.filePath,
							imgWidth: res.width
						})
						this.loading = false
					}
				});
			},
			uploading2(f) {
				this.loading = true
				this.dataApi.upload('FileUploadNotify/upload', f.file, res => {
					if (res.responseType == 'S') {
						f.images.splice(f.index, 1, res.filePath)
						this.storeImgDtos.push({
							imgHeight: res.height,
							imgUrl: res.filePath,
							imgWidth: res.width
						})
						this.loading = false
					}
				});
			},
			uploading3(f) {
				this.loading = true
				this.dataApi.upload('FileUploadNotify/upload', f.file, res => {
					if (res.responseType == 'S') {
						f.images.splice(f.index, 1, res.filePath)
						this.storeImgDtoList.push({
							imgHeight: res.height,
							imgUrl: res.filePath,
							imgWidth: res.width
						})
						this.loading = false
					}
				});
			},

			deleteRow(index, rows) {
				rows.splice(index, 1);
			},
			countAll() {
				var all = 0
				for (var i = this.form.standardInfoIdPojos.length - 1; i >= 0; i--) {
					all = all + parseInt(this.form.standardInfoIdPojos[i].stock)
				}
				return all;
			},
			checkNum(item) {
				if (!isFloat(item.skuPrice)) {
					this.showMsg('价格只能输入正数', 'warning')
					item.skuPrice = 0
				} else {
					item.skuPrice = parseFloat(Math.abs(item.skuPrice))
				}
				let compare = (x,y) => {
				    if(x < y){
				        return -1
				    }else if(x > y){
				        return 1;
				    }else{
				        return 0;
				    }
				}
				
				let arr = []
				this.form.goodSkuWebDtos.forEach((items,index) => {
				
					arr.push(items.skuPrice)
				})
				this.form.storeGoodDto.goodPrice = arr.sort(compare)[0]

			},
			addTexture() {
				this.storeGoodParamDtos.push({
					paramName: '',
					paramKey: ''
				})
			},
			delTexture(index, rows) {
				if (rows.length == 1) {
					this.showMsg('产品参数不能少于一条', 'warning')
					return
				}
				rows.splice(index, 1)
			},
			handleClose() {
				/**
				 * 方法说明
				 * author: liuchen
				 * description: 关闭新增分组弹框
				 * @param
				 * @return 
				 * @createTime: 2020-10-9 11:51:51
				 */
				let vm = this
				vm.dialogVisible = false
				vm.dialogVisibleAddSku = false
			},
			handleCloseSku(item) {
			  if (item.spuId) {
			      this.dataApi.ajax('editShopSpuDetail',{spuId:item.spuId}, res => {
			          if (res.responseType === 'S') {
			               for (var i = this.dynamicTags.length - 1; i >= 0; i--) {
			                  if (item.spuId==this.dynamicTags[i].spuId) {
			                     this.dynamicTags.splice(i,1)
			                     break;
			                  }
			                }
			          }
			
			      }); 
			  }else{
			    for (var i = this.dynamicTags.length - 1; i >= 0; i--) {
			      if (item.spuName==this.dynamicTags[i].spuName) {
			         this.dynamicTags.splice(i,1)
			         break;
			      }
			    }
			  }
			  
			  
			},
			showInput() {
			              this.inputVisible = true;
			              this.$nextTick(_ => {
			                this.$refs.saveTagInput.$refs.input.focus();
			              });
			            },
			handleInputConfirm() {
			  let inputValue = this.inputValue;
			  inputValue=inputValue.trim()
			  inputValue=inputValue.replace(/[, ]/g,'')
			  if (inputValue) {
			    if (!this.check(inputValue)) {
			      this.dynamicTags.push({spuName:inputValue});
			    }else{
			      this.showMsg('属性不可以重复','warning')
			      return;
			    }
			  }
			  this.inputVisible = false;
			  this.inputValue = '';
			},
			submit(){
			  if (!this.standard) {
			    this.$message({
			        type: 'warning',
			        message: '请输入规格名称!'
			      });
			    return;
			  }
			  if (this.dynamicTags.length==0) {
			     this.$message({
			        type: 'warning',
			        message: '请添加属性!'
			      });
			    return;
			  }
			   if (this.addSizeType =='add') {
			     var arr=[]
			     for (var i=0;i< this.dynamicTags.length; i++) {
			       arr.push(this.dynamicTags[i])
			     }
			    var data={
			       spuName:this.standard,
			       shopSpuSecDtos:arr
			    }
			    this.dataApi.ajax('addShopSpu',data, res => {
			               if (res.responseType === 'S') {
			                    this.showMsg('新增成功')
								this.fetchStandard()
								this.dialogVisibleAddSku = false
			               }
			           });
			   }else{
			        var arr=[]
			         for (var i = 0;i<this.dynamicTags.length; i++) {
			           if (!this.dynamicTags[i].spuId) {
			              arr.push({spuName:this.dynamicTags[i].spuName})
			           }
			           
			         }
			        var data={
			           spuName:this.standard,
			           shopSpuSecDtos:arr,
			           spuId:this.addSizeSpuId
			        }
			        this.dataApi.ajax('editShopSpu',data, res => {
			                   if (res.responseType === 'S') {
			                        this.showMsg('修改成功')
			                        this.fetchStandard()
									this.getEditList()
									this.dialogVisibleAddSku = false
			                   }
			               });
			      }
			  },
			  getEditList() {
				  let vm = this
				this.dataApi.ajax('selectShopSpuList', {
					spuId: vm.addSizeSpuId
				}, res => {
					//console.log(res.standardTagPojos)
					if (res.responseType === 'S') {
						vm.option_array.forEach((item, index) => {
							if(item.spuId == vm.addSizeSpuId) {
								vm.option_array.splice(index,1)
								vm.option_array.push({
									spuName: vm.standard,
									spuId: vm.addSizeSpuId,
									goodSpuWebSecDtos: res.shopSpuPojos,
									type_tag: [],
								})
							}
						})
					}
				});  
			  },
			check(name){
			  for (var i = this.dynamicTags.length - 1; i >= 0; i--) {
			    if (name==this.dynamicTags[i].spuName) {
			       return true
			       break;
			    }
			  }
			},
			addGroup() {
				let vm = this
				vm.dialogVisible = true
				vm.formInline = {
					cateId: '',
					cateName: '',
					storeId: vm.storeId,
					cateParentId: 0,
					cateType: '1',
					cateState: '1',
					cateShow: '1',
					cateSort: '0'
				}
			},
			confirmAddGroup(data) {
				/**
				 * 方法说明
				 * author: liuchen
				 * description: 确定新增分组 
				 * @param 
				 * @return 
				 * @createTime: 2020-10-9 11:53:14
				 */
				let vm = this
				if(data != undefined){
					console.log(data)
				}
				let obj = generateObj(vm.formInline)
				console.log(obj)
				if (obj.cateId) {
					vm.dataApi.ajax('editGoodCate', obj, res => {
						if (res.responseType === 'S') {
							vm.showMsg('修改成功')
							vm.dialogVisible = false
							vm.selectSort()
						}
					});
				} else {
					vm.dataApi.ajax('addGoodCate', obj, res => {
						if (res.responseType === 'S') {
							vm.showMsg('添加成功')
							vm.dialogVisible = false
							vm.selectSort()
						}
					});
				}
			},
			querySearch(queryString, cb) {
				let restaurants = this.sku_spec_array
				restaurants.forEach(item => {
					item.value = item.spuName
				})
				let results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants
				cb(results);
			},
			createFilter(queryString) {
				return (restaurant) => {
					return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0)
				};
			},
			handleSelect(item) {
				let vm = this
				let i = 0
				console.log(item)
				vm.newSkuInfo.forEach((items, index) => {
					if(items.skuName === item.spuName){
						i = index
					}
				})
				vm.dataApi.ajax('selectShopSpuList', {
					spuId: item.spuId
				}, res => {
					//console.log(res.standardTagPojos)
					if (res.responseType === 'S') {
					
						// vm.$set(vm.newSkuInfo[i], 'goodSku', res.shopSpuPojos)
						vm.newSkuInfo[i].goodSku = res.shopSpuPojos
					}
				})
				
			},
			addSkuSpuName(index) {
				let vm = this
				let data = {
					spuName: ''
				}
				if(vm.newSkuInfo[index].skuLis.length == vm.newSkuInfo[index].goodSku.length){
					vm.showMsg('请前往添加规格值')
					return
				}
				vm.newSkuInfo[index].skuLis.push(data)
				if(vm.newSkuInfo.length > 0 ) {
					vm.disabledPrice = true
				}
			},
			addSkuList() {
				/**
				 * 方法说明
				 * author: liuchen
				 * description: 添加规格项目
				 * @param 
				 * @return 
				 * @createTime: 2020-10-9 14:30:23
				 */
				let vm = this
				let data = {
					skuName: '',
					skuLis: [
						{
							spuName: ''
						}
					],
					goodSku:[]
				}
				vm.disabledPrice = true
				if(vm.newSkuInfo.length == 3) {
					vm.showMsg('最多添加三组规格')
					return
				}
				vm.newSkuInfo.push(data)
			},
			deleteSpuName(index, i) {
				let vm = this
				vm.newSkuInfo[index].skuLis.splice(i, 1)
				if(vm.newSkuInfo.length == 1 && vm.newSkuInfo[0].skuLis.length == 0 ) {
					vm.disabledPrice = false
				}
			},
			showSkuTable(e) {
				let vm = this
				let arr = JSON.parse(JSON.stringify(vm.newSkuInfo))
				let objArr = []
				var select = [];
				let arrHeader = []
				for (var i in arr) {
					if (arr[i].skuLis.length > 0) {
						select.push(arr[i].skuLis)
					} else {
						return false;
					}
					if(arr[i].skuName != '') {
						arrHeader.push({
							skuName: arr[i].skuName
						})
					}
				}
				vm.tableSkuInfo = arrHeader
				var ret = vm.doExchangeNew(select)
				for (var i = 0; i < ret.length; i++) {
					var proObj = {};
					var retArr = ret[i].spuName.split('|');
					proObj['goodSkuWebSecDtos'] = [];
					for (var y = 0; y < retArr.length; y++) {
						proObj['goodSkuWebSecDtos'].push({
							spuName: retArr[y]
						})
					}
					proObj['skuIcon'] = [];
					proObj['skuPrice'] = 0;
					objArr.push(proObj);
				}
				this.tableData = objArr
				// this.getRowSapn(tb, 0, 0, 0)
			},
			getRowSapn(tb, startRow, endRow, col) {
				 if (col >= tb.rows[0].cells.length) {
				 return;
				 }
				 if (col == 0) { endRow = tb.rows.length-1; }
				 for (var i = startRow; i < endRow; i++) {
				 if (tb.rows[startRow].cells[col].innerHTML == tb.rows[i + 1].cells[0].innerHTML) { 
				 tb.rows[i + 1].removeChild(tb.rows[i + 1].cells[0]);
				 tb.rows[startRow].cells[col].rowSpan = (tb.rows[startRow].cells[col].rowSpan | 0) + 1;
				 if (i == endRow - 1 && startRow != endRow) {
				 this.getRowSapn(tb, startRow, endRow, col + 1);
				 }
				 } else {
				 this.getRowSapn(tb, startRow, i + 0, col + 1);
				 startRow = i + 1;
				 }
				 }
			},
			doExchangeNew(doubleArrays) {
				var len = doubleArrays.length;
				if (len >= 2) {
					var len1 = doubleArrays[0].length;
					var len2 = doubleArrays[1].length;
					var newLen = len1 * len2;
					var temp = new Array(newLen);
					var index = 0;
			
					for (var i = 0; i < len1; i++) {
						for (var j = 0; j < len2; j++) {
							let obj = {
								spuName: ''
							}
							obj.spuName = doubleArrays[0][i].spuName + '|' + doubleArrays[1][j].spuName;
							temp[index] = obj
							index++;
						}
					}
					var newArray = new Array(len - 1);
					console.log(newArray)
					for (var i = 2; i < len; i++) {
						newArray[i - 1] = doubleArrays[i];
					}
					newArray[0] = temp;
					return this.doExchangeNew(newArray);
			
				} else {
					return doubleArrays[0];
				}
			},
		}
	}
</script>
